import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/net/post_request.dart';
import 'package:ls_work/net/response/response_data.dart';
import 'package:ls_work/net/response/service_item_list.dart';

class ServiceItemListViewModel extends BaseListViewModel<ServiceItemList>{
  ServiceItemListViewModel(BuildContext context) : super(context);

  @override
  Future<List<ServiceItemList>> requestListData() async {
    var data = await PostRequest.serviceItemList(page, pageLength);
    var bean = ResponseBean.fromJson(data);
    if("0"==bean.code){
      var list = ((bean.data as List?)??[]).map((e) => ServiceItemList.fromJson(e)).toList();
      return list;
    }else{
      throw bean.msg??"";
    }
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }

}